<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>常见居中的表示方法</title>
</head>
<body>
    方法一：table-cell
<code>
    <div class="box box1">
        <span>垂直居中</span>
</div>

<code>
    .box1{
    	display: table-cell;
    	vertical-align: middle;
    	text-align: center;			
    }
</code>

<p>2 display:flex</p>
<code>
    .box2{
        display: flex;
        justify-content:center;
        align-items:Center;
    }
</code>

 
3 方法3：绝对定位和负边距
<code>
    

.box3{position:relative;}
.box3 span{
            position: absolute;
            width:100px;
            height: 50px;
            top:50%;
            left:50%;
            margin-left:-50px;
            margin-top:-25px;
            text-align: center;
        }


</code>

方法5：translate

<code>
    .box6 span{
        position: absolute;
        top:50%;
        left:50%;
        width:100%;
        transform:translate(-50%,-50%);
        text-align: center;
    }
</code>

方法7：display:flex和margin:auto

<code>
    .box8{
        display: flex;
        text-align: center;
    }
    .box8 span{margin: auto;}
</code>
</body>
</html>